#
# Makefile to make the file libclientserver.a, containing
# connection.o and server.o
#

CXX		 = g++
CXXFLAGS	 = -ggdb  -Wall -W -Werror -pedantic-errors
CXXFLAGS	+= -Wmissing-braces -Wparentheses -std=c++0x
# The following option cannot be used since some of the socket
# macros give warnings on "old-style-cast"
#CXXFLAGS	+= -Wold-style-cast

SRC	= $(wildcard src/*.cc)
VPATH=src

.PHONY: all

all: myserver myclient move clean  

myserver: myserver.o messagehandler.o connection.o server.o memdata.o hdddata.o article.o newsgroup.o
	$(CXX) -o $@ $^

myclient: myclient.o terminalHandler.o messagehandler.o connection.o 	
	$(CXX) -o $@ $^

.PHONY: clean	
	
clean: #removes all .o and .d files
	$(RM) *.o
	$(RM) src/*.d
.PHONY: move

move:
	cp -f myserver bin/
	cp -f myclient bin/
	rm myserver
	rm myclient
	
.PHONY: uninstall

uninstall:
	rm -r bin/*
	

%.d: %.cc
	@set -e; rm -f $@; \
	 $(CXX) -MM $(CXXFLAGS) $< > $@.$$$$; \
	 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
	 rm -f $@.$$$$

include $(SRC:.cc=.d)
